<?php

class userTable extends Doctrine_Table
{
    public function getProfil($id) {
        
        $q = $this->createQuery('u')
                ->leftJoin('u.setKota k')
                ->leftJoin('u.setPropinsi p')
                ->where('u.id = ?', $id);

        return $q->fetchOne();
    }

    public function getIdSekolah($id_user) {
        $q = Doctrine_Query::create()
                ->select('id_sekolah')
                ->from('user u')
                ->where('id = ?', $id_user);

        $q = $q->fetchOne();
        return $q->getIdSekolah();
    }

    public function searchTeman($param) {
        $q = $this->createQuery('u')
                ->where('u.nama LIKE (?)', '%'. $param . '%');

        return $q->execute();
    }

    public function getUserList() {
        $q = Doctrine_Query::create()
                ->select('id, nama')
                ->from('user u')
                ->where('u.id_profesi <> ?', 1);

        $q = $q->execute();

        $result = array();
        foreach($q as $r) {
            $result[$r->getId()] = $r->getNama();
        }

        return $result;
    }

}